home *** CD-ROM | disk | FTP | other *** search
- Path: maui.cc.odu.edu!news
- From: "CLEVELAND O. BURNETT" <cob@cs.odu.edu>
- Newsgroups: comp.lang.c++
- Subject: Does anyone understand linked lists in C++
- Date: Thu, 4 Apr 1996 21:06:11 -0500 (EST)
- Organization: Old Dominion University
- Message-ID: <Pine.SUN.3.90.960404204802.4582A-100000@daffodil.cs.odu.edu>
- NNTP-Posting-Host: daffodil.cs.odu.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
-
-
-
-
- struct students {
- char firstname[20];
- char middle_initial;
- char lastname[20];
- char address1[40];
- char address2[30];
- char phone_number[7];
- char email[50];}
-
-
- I am trying to do two thing with this structure. First, I am trying to
- read this struct from a data file that I created and second, I am
- trying to create a linked list of this struct. The compiler that I am
- using is the g++ compiler. How would I accomplish this? Please show me
- how can I modify or change my procedures to accomplish my goal?
-
- I tried using these procedures that I created and each failed.
- The first procedure is for reading the struct and the second is for
- created the linked list
-
-
-
- void Read(ifstream &infile, students data)
-
- {
- infile >> data.firstname[20];
- infile >>data.middle_initial;
- infile >> data.lastname[20];
- infile >> data.address1[40];
- infile >> data.address2[30];
- infile >> data.phone_number[7];
- infile >> data.email[50];
- infile >> data.dept[16];
- infile >> data.edu_level[9];
- }
-
-
-
-
- void AddLastStudentRec(studentRec &List, students data)
- {
- Entry newNode = new Node;
-
- newNode->data = data;
- newNode->next = 0;
- if (List.last == NULL)
- {
- List.first = newNode;
- List.last = newNode;
-
-
- else
- {
- List.last->next = newNode;
- List.last = newNode;
- }
- }
-
-
- thank you,
- cleveland
-
-
-
-
-